# -*- coding: utf-8 -*-

from PyQt5.QtWidgets import QWidget, QApplication, QTextEdit, QVBoxLayout, QPushButton
import sys


class Text(QWidget):
    def __init__(self):
        super(Text, self).__init__()

        self.setWindowTitle("QTextEdit例子")

        self.text = QTextEdit()
        self.btn1 = QPushButton("显示文本")
        self.btn2 = QPushButton("显示HTML")

        layout = QVBoxLayout()  # 垂直布局
        layout.addWidget(self.text)
        layout.addWidget(self.btn1)
        layout.addWidget(self.btn2)

        self.setLayout(layout)

        self.btn1.clicked.connect(self.bt1_clicked)
        self.btn2.clicked.connect(self.bt2_clicked)

    def bt1_clicked(self):
        self.text.setPlaceholderText("你好，我是清安")

    def bt2_clicked(self):
        self.text.setPlaceholderText("<font color='red' size=6>你好，我是清安</font>")

if __name__ == '__main__':
    app = QApplication(sys.argv)
    t = Text()
    t.show()
    sys.exit(app.exec_())